#include #include #include #include #include using namespace std; void getTableDimensions(int &rows,int &cols) { cout<<"Enter the number of columns: "; cin>>cols; cout<<"Enter the number of rows: "; cin>>rows; } vector> getTableData(int rows,int cols) { vector> table(rows,vector(cols)); cout<<"Enter the table data (headers in the first row):\n"; for (int i=0;i>ws; getline(cin,table[i][j]); } } return table; } string generateHTMLContent(const vector> &table,int rows,int cols) { string htmlContent = R"(

HTML Table

)"; for (int i=0;i\n"; else htmlContent+=" \n"; } htmlContent+=" \n"; } htmlContent+=R"(
"+table[i][j]+"
)"; return htmlContent; } string getDesktopPath() { char *userProfile=nullptr; size_t len; _dupenv_s(&userProfile,&len,"USERPROFILE"); if (userProfile==nullptr) { cerr << "Unable to get user profile path.\n"; exit(1); } string desktopPath=string(userProfile)+"\\Desktop\\HTML_Table"; free(userProfile); string command="mkdir \""+desktopPath+"\" >nul 2>&1"; system(command.c_str()); return desktopPath+"\\table.html"; } void saveHTMLToFile(const string &htmlContent,const string &filePath) { ofstream htmlFile(filePath); if (htmlFile.is_open()) { htmlFile<> table=getTableData(rows,cols); string htmlContent=generateHTMLContent(table,rows,cols); string filePath=getDesktopPath(); saveHTMLToFile(htmlContent,filePath); return 0; }